package cn.group.service.impl;

import cn.group.mapper.LineChartMapper;
import cn.group.service.LineChartService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.entity.Record;
import pojo.entity.User;
import pojo.qo.UserLog;
import utils.GetLineChart;

import java.util.List;

@Service
public class LineChartServiceImpl implements LineChartService {

    @Autowired
    LineChartMapper lineChartMapper;

    GetLineChart getLineChart=new GetLineChart();


    @Override
    public List<UserLog> getLogMassage(int newPages) {
        // 定义传参
        int page = newPages;// 当前页数
        int rows = 12;//一页多少条数据
        PageHelper.startPage(page,rows);
        List<UserLog> records = lineChartMapper.userLog();
        return records;
    }

    @Override
    public void deleteLog(Long id) {
        int i = lineChartMapper.deleteLog(id);
//        System.out.println(i);
    }

    @Override
    public int[] userDate() {

        List<Record> records = lineChartMapper.userDate();

        int[] days = getLineChart.getUserDate(records);

        return days;
    }

    @Override
    public int[] userLogin() {

        List<Record> records = lineChartMapper.userLogin();

        int[] days = getLineChart.getUserLoginAndRegister(records);

        return days;
    }

    @Override
    public int[] userRegister() {

        List<Record> records = lineChartMapper.userRegister();

        int[] days = getLineChart.getUserLoginAndRegister(records);

        return days;
    }

    @Override
    public int[] userOrder() {

        List<Record> records = lineChartMapper.userOrder();

        int[] days = getLineChart.getUserOrder(records);

        return days;
    }

    @Override
    public int[] userGood() {

        List<Record> records = lineChartMapper.userGood();

        int[] days = getLineChart.getUserGood(records);

        return days;
    }
}
